package cn.tedu.task;

import javax.swing.*;

/**
 * 设计战舰类
 */
public class Battleship extends SeaObject {
    private int life;//命属性

    /**
     * Instantiates a new Battleship.
     */
    public Battleship() {
        super(66, 26, 270, 124, 20);
        life = 5;
    }


    @Override
    public void move() {
    }

    @Override
    public ImageIcon getImage() {
        return Images.battleship; //返回战舰图片
    }

    /**
     * 发射炸弹方法：生成炸弹对象
     *
     * @return 炸弹对象 bomb
     */
    public Bomb shootBomb(){
        return new Bomb(this.x, this.y); //炸弹的初始坐标就是战舰的坐标
    }

    /**
     * 战舰左移
     */
    public void moveLeft(){
        x-=speed;
    }

    /**
     * 战舰右移
     */
    public void moveRight(){
        x+=speed;
    }

    /**
     * 战舰增加命 @param num the num
     *
     * @param num the num
     */
    public void addLife(int num){
        life+=num;
    }

    /**
     * 战舰增减命 @param num the num
     *
     * @param num the num
     */
    public void subtractLife(int num){
        life-=num;
    }

    /**
     * Get life int.
     *
     * @return the int
     */
    public int getLife(){
        return life;
    }

}














